package ccapp;

import java.util.Calendar;
import java.util.List;

import frmsystem.Entry;
import frmsystem.IAccount;
import frmsystem.IEntry;
import ccapp.util.*;

public class Charge extends Entry{

	public Charge(IAccount acc){
		super(acc);		
	}	
	
	public void execute(){				
		if(account.getBalance() > amount){
			account.setBalance(account.getBalance() - amount);
		}		
	}

	public double getTotal(List<IEntry> entries, Calendar calendarFirst, Calendar calendarLast){
		double total = 0;
		for(IEntry entry : entries){
			if(calendarFirst.after(entry.getDate()) && calendarLast.before(entry.getDate())){
				if(entry.equals(this)){
					total += entry.getAmount();
				}
				   			
			}
		}
		return total;
		
	}
	
	
	
	
	
}